#include <iostream>
#include <thread>
#include <cstdlib>

#include "application.hpp"

#define app Application::Instance()

void atexit_handler()
{
    std::cout << "at exit" << std::endl;
}

void thread_func()
{
    std::this_thread::sleep_for(std::chrono::milliseconds(1000));
    std::cout << app->GetApplicationDirPath() << std::endl;
    std::cout << app->GetApplicationFilePath() << std::endl;
    std::cout << app->GetApplicationName() << std::endl;
    std::cout << app->GetOriginalArguments()[0] << std::endl;
    app->Exit(3);
    std::this_thread::sleep_for(std::chrono::milliseconds(1000));
}

int main(int argc, char* argv[])
{
    app->Initialize(argc, argv);
    std::atexit(atexit_handler);

    std::thread th(thread_func);
    th.detach();

    return app->Exec();
}